/**
 * 2024/01/01 - 2024/12/31
 **/
package com.snail.camunda.engin.identity.controller;

import com.snail.camunda.engin.identity.dto.GroupInsertDTO;
import com.snail.camunda.engin.identity.dto.GroupModifyDTO;
import com.snail.camunda.engin.identity.dto.GroupQueryDTO;
import com.snail.camunda.engin.identity.manager.GroupManager;
import com.snail.camunda.engin.identity.vo.GroupVO;
import com.snail.starter.commons.page.PageQO;
import com.snail.starter.commons.page.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 * @author: (zg)
 * @Date: 2024/12/16 16:51
 * @Version: 1.0.0
 */
@Api(tags = {"分组管理"})
@RestController
@RequestMapping("/tenant/{tenantId}/group")
public class GroupController {

    @Resource
    GroupManager groupManager;

    @PostMapping
    @ApiOperation("新增分组")
    public String add(@PathVariable("tenantId") String tenantId,  @RequestBody GroupInsertDTO dto){
        return groupManager.add(tenantId, dto);
    }

    @PutMapping("/{id}")
    @ApiOperation("修改分组")
    public boolean modify(@PathVariable("id") String id, @RequestBody GroupModifyDTO dto){
        return groupManager.modify(id, dto);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除分组")
    public boolean delete(@PathVariable("id") String id){
        return groupManager.delete(id);
    }

    @GetMapping("/{id}")
    @ApiOperation("查询分组")
    public GroupVO queryById(@PathVariable("id") String id){
        return groupManager.queryById(id);
    }

    @PostMapping("/groups")
    @ApiOperation("分组列表")
    public List<GroupVO> list(@RequestBody GroupQueryDTO dto){
        return groupManager.list(dto);
    }

    @PostMapping("/pages")
    @ApiOperation("分组分页")
    public PageVO<GroupVO> page(@RequestBody PageQO<GroupQueryDTO> page){
        return groupManager.page(page);
    }

}